﻿namespace Microsoft.SharePoint.Client
{
    using System;
    using System.ComponentModel;

    [ScriptType("SP.Navigation", ServerTypeId="{d6aa87a7-71b3-4bbe-bca7-00ab1bd7d37f}")]
    public class Navigation : ClientObject
    {
        [EditorBrowsable(EditorBrowsableState.Never)]
        public Navigation(ClientRuntimeContext Context, ObjectPath ObjectPath) : base(Context, ObjectPath)
        {
        }

        protected override bool InitOnePropertyFromJson(string peekedName, JsonReader reader)
        {
            bool flag = base.InitOnePropertyFromJson(peekedName, reader);
            if (!flag)
            {
                string str = peekedName;
                if (str == null)
                {
                    return flag;
                }
                if (!(str == "TopNavigationBar"))
                {
                    if (str == "QuickLaunch")
                    {
                        flag = true;
                        reader.ReadName();
                        this.QuickLaunch.FromJson(reader);
                        return flag;
                    }
                    if (str == "UseShared")
                    {
                        flag = true;
                        reader.ReadName();
                        base.ObjectData.Properties["UseShared"] = reader.ReadBoolean();
                    }
                    return flag;
                }
                flag = true;
                reader.ReadName();
                this.TopNavigationBar.FromJson(reader);
            }
            return flag;
        }

        [Remote]
        public NavigationNodeCollection QuickLaunch
        {
            get
            {
                object obj2;
                if (base.ObjectData.ClientObjectProperties.TryGetValue("QuickLaunch", out obj2))
                {
                    return (NavigationNodeCollection) obj2;
                }
                NavigationNodeCollection nodes = new NavigationNodeCollection(base.Context, new ObjectPathProperty(base.Context, base.Path, "QuickLaunch"));
                base.ObjectData.ClientObjectProperties["QuickLaunch"] = nodes;
                return nodes;
            }
        }

        [Remote]
        public NavigationNodeCollection TopNavigationBar
        {
            get
            {
                object obj2;
                if (base.ObjectData.ClientObjectProperties.TryGetValue("TopNavigationBar", out obj2))
                {
                    return (NavigationNodeCollection) obj2;
                }
                NavigationNodeCollection nodes = new NavigationNodeCollection(base.Context, new ObjectPathProperty(base.Context, base.Path, "TopNavigationBar"));
                base.ObjectData.ClientObjectProperties["TopNavigationBar"] = nodes;
                return nodes;
            }
        }

        [Remote]
        public bool UseShared
        {
            get
            {
                base.CheckUninitializedProperty("UseShared");
                return (bool) base.ObjectData.Properties["UseShared"];
            }
            set
            {
                base.ObjectData.Properties["UseShared"] = value;
                if (base.Context != null)
                {
                    base.Context.AddQuery(new ClientActionSetProperty(this, "UseShared", value));
                }
            }
        }
    }
}

